home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-09-02 | 3.0 KB | 101 lines | [TEXT/CCL2] |
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;
- ;; Pict-Scrap.Lisp
- ;;
- ;; This version works with MCL 2.0ß1p3.
- ;;
- ;; Written by Mark Johnson, Cognitive Science, Brown University.
- ;; Email: mj@cs.brown.edu
- ;;
- ;; This file a scrap-handler for scraps of type PICT
- ;;
- ;; Once this is installed, windows which copy and paste PICTs will
- ;; be able to share their work with other applications
- ;;
-
- (in-package :ccl)
-
- (defclass pict-scrap-handler (scrap-handler) ())
-
- (defmethod set-internal-scrap ((self pict-scrap-handler) scrap)
- (declare (ignore scrap))
- (let ((old-pict (get-internal-scrap self)))
- (when (handlep old-pict)
- (#_KillPicture old-pict))) ;dispose of the old pict before we
- ;put a new one in its place
- ;this will crash if your program has
- ;other pointers to the pict, so
- ;always make sure cut/copy really do
- ;-copy- the pict
- (call-next-method))
-
- (defmethod externalize-scrap ((self pict-scrap-handler))
- (let ((the-pict (get-internal-scrap self)))
- (when the-pict
- (let ((size (#_GetHandleSize the-pict)))
- (with-dereferenced-handles ((p the-pict))
- (#_PutScrap size :pict p))))))
-
- (defmethod internalize-scrap ((self pict-scrap-handler))
- (let ((the-pict (#_NewHandle 0)))
- (rlet ((offset :integer))
- (#_GetScrap the-pict :pict offset)
- (set-internal-scrap self the-pict))))
-
- (unless (assoc :pict *scrap-handler-alist*)
- (push `(:pict . ,(make-instance 'pict-scrap-handler))
- *scrap-handler-alist*))
-
- (provide :pict-scrap)
-
- #|
- ;;;;;;;;;;;;;;;;;;;;;
- ;;
- ;; a simple window, supporting cut and paste with picts
- ;;
- ;; because it doesn't remember the picts which it pastes,
- ;; it can only cut a pseudo-pict, that is, a pict which
- ;; contains the window's current contents as a bitmap.
-
-
- (defclass pict-window (window) ())
-
- (defmethod paste ((self pict-window))
- (let ((pict (get-scrap :pict)))
- (when pict
- (with-focused-view self
- (rlet ((r :rect))
- (with-dereferenced-handles ((pict-point pict))
- (copy-record (rref pict-point :picture.picframe
- :storage :pointer)
- :rect
- r))
- (#_DrawPicture pict r))))))
-
- (defmethod copy ((self pict-window))
- (let* ((wptr (wptr self))
- (rect (rref wptr :window.portrect)))
- (with-focused-view self
- (let* ((pict (#_OpenPicture rect))
- (bits (rref wptr :window.portbits)))
- (#_CopyBits bits
- bits
- rect
- rect
- 0 ;transfer mode
- (%null-ptr))
- (#_ClosePicture)
- (put-scrap :pict pict)))))
-
- (defmethod clear ((self pict-window))
- (with-focused-view self
- (#_EraseRect (rref (wptr self) :window.portrect))))
-
- (defmethod cut ((self pict-window))
- (copy)
- (clear))
-
- (make-instance 'pict-window)
-
-
- |#